import 'package:flutter/material.dart';
import 'package:get/get_utils/get_utils.dart';

class EarningsButtonsWidget extends StatelessWidget {
  EarningsButtonsWidget({Key? key}) : super(key: key);
  final titles = ["奉献值", "我的团队", "收益明细"];
  final imageNames = [
    "assets/images/icon_mine_dedication.png",
    "assets/images/icon_mine_team.png",
    "assets/images/icon_mine_income.png",
  ];
  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceAround,
      children: buildWidgets(titles.length),
    );
  }

  List<Widget> buildWidgets(int count) {
    List<Widget> widgets = [];
    for (int i = 0; i < count; i++) {
      widgets.add(
        Expanded(
          child: EarningsButtonsItemWidget(
            imageName: imageNames[i],
            title: titles[i],
          ),
        ),
      );
    }
    return widgets;
  }
}

class EarningsButtonsItemWidget extends StatelessWidget {
  final String imageName;
  final String title;
  const EarningsButtonsItemWidget({
    Key? key,
    required this.imageName,
    required this.title,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Image.asset(imageName, width: 76, height: 59, fit: BoxFit.cover),
        SizedBox(height: 8),
        Text(
          title,
          style: TextStyle(
            color: Colors.white,
            fontSize: 16,
            fontWeight: FontWeight.bold,
          ),
        ),
      ],
    ).marginOnly(right: 0);
  }
}
